package org.example.demo3.untils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public  abstract  class EmptyUtil {
    public static boolean isNullOrEmpty(String str) {
        if (str == null || "".equals(str.trim()) || "null".equalsIgnoreCase(str.trim()) || "undefined".equalsIgnoreCase(str.trim())) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isNullOrEmpty(StringBuffer str) {
        return (str == null || str.length() == 0);
    }

    public static boolean isNullOrEmpty(String[] str) {
        if (str == null || str.length == 0) {
            return true;
        } else {
            return false;
        }
    }


    public static boolean isNullOrEmpty(Object obj) {
        if (obj == null || "".equals(obj)) {
            return true;
        } else {
            return false;
        }
    }


    public static boolean isNullOrEmpty(Object[] obj) {
        if (obj == null || obj.length == 0) {
            return true;
        } else {
            return false;
        }
    }


    public static boolean isNullOrEmpty(Collection collection) {
        if (collection == null || collection.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }


    @SuppressWarnings("rawtypes")
    public static boolean isNullOrEmpty( Map map) {
        if (map == null || map.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }


    public static <T> List<T> removeNullUnit(List<T> xllxList) {
        List<T> need = new ArrayList<T>();
        for (int i = 0; i < xllxList.size(); i++) {
            if (!isNullOrEmpty(xllxList.get(i))) {
                need.add(xllxList.get(i));
            }
        }
        return need;
    }

}
